﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Annotations
{
    [Serializable]
    public class GoogleSearchAnnotation : IAnnotation, IWebSearchable
    {
        public GoogleSearchAnnotation(string snpName)
        {
            this.SnpName = snpName;
        }

        public Uri SearchUri
        {
            get
            {
                string searchUri = String.Format("http://www.google.co.uk/search?hl=en&q={0}&meta=", this.SnpName ?? String.Empty);
                return new Uri(searchUri);
            }
        }

        public string SummaryText
        {
            get { return String.Format("Google search on {0}", this.SnpName ?? "<null>"); }
        }

        private string SnpName { get; set; }

        public AnnotationKey AnnotationKey
        {
            get { return AnnotationKey.GoogleSearch; }
        }

        public string EncodedKey
        {
            get
            {
                return "<annotation type=\"Google\"><snpName>" + System.Security.SecurityElement.Escape(SnpName) + "</snpName><url>" + System.Security.SecurityElement.Escape(SearchUri.ToString()) + "</url></annotation>";
            }
        }

        public string Description
        {
            get { return SummaryText; }
        }
    }
}
